package com.chaidb;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.db.DbConnection;

public class DeleteAShareMarker {
	@SuppressWarnings({ "finally", "unchecked" })
	public ArrayList doDeleteAShareMarker(String markerid,String userid)
	{
		System.out.println("I am here deleteA shared Marker");
		System.out.println(markerid + " " + userid);
		float id =  Float.valueOf(markerid); 
		int i = (int)id;
		markerid = Integer.toString(i);
		id =  Float.valueOf(userid); 
		i = (int)id;
		userid = Integer.toString(i);
		String sql = "delete from marker_share where mid='" + markerid +"' && uid='" + userid +"';";
		System.out.println(sql);
	
		ArrayList markers = new ArrayList();
		Connection con = null;
		System.out.println(userid);
		try {
			con = DbConnection.getInstance().getConnection();
			Statement st2 = con.createStatement();
			int rs = st2.executeUpdate(sql);
			if(rs == 1){
				ShowAllShareMarkers db = new ShowAllShareMarkers();
				markers = db.doShowAllShareMarkers(userid);
			}
		}catch(SQLException e)
		{
			e.printStackTrace();
		}finally
		{
			try {
				con.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
			return markers;
		}
	}

}
